//
//  PictureDetailViewController.m
//  MilitaryDemo
//
//  Created by qianfeng01 on 15-7-5.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "PictureDetailViewController.h"
#import "AFNetworking.h"
#import "UIImageView+WebCache.h"
#import "PictureScrollView.h"
@interface PictureDetailViewController ()
@property(nonatomic,strong)NSMutableArray *imgurlsArr;
@property(nonatomic,strong)NSMutableArray *descArr;
@property(nonatomic,strong)PictureScrollView *PicView;
@property(nonatomic,strong)UIPageControl *pageControl;
@end

@implementation PictureDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor blackColor];
    [self downloadData];
}
-(void)creatScrollView:(NSMutableArray *)imgurlArr descArr:(NSMutableArray *)descArr
{
    self.PicView=[[PictureScrollView alloc]initWithFrame:CGRectMake(0,0, kScreenSize.width , kScreenSize.height)];
    self.PicView.backgroundColor=[UIColor blackColor];
    self.PicView.title=self.Pictitle;
    self.PicView.imageNames=imgurlArr;
    self.PicView.textArr=descArr;
    
    self.PicView.showsHorizontalScrollIndicator=NO;
    [self.view addSubview:self.PicView];
}
-(void)downloadData
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    NSString *url=[NSString stringWithFormat:kPicsDetailUrl,self.id];
    __weak typeof (self) weakSelf=self;
    [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        if (responseObject) {
            NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
            weakSelf.imgurlsArr=[[NSMutableArray alloc]init];
            weakSelf.descArr=[[NSMutableArray alloc]init];
            weakSelf.imgurlsArr=dict[@"imgurls"];
            weakSelf.descArr=dict[@"desc"];
            
        }
        [self creatScrollView:weakSelf.imgurlsArr descArr:weakSelf.descArr];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"图片详情下载错误");
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
